/**
 * 给定一个只有小写英文字母组成的字符串，串长为n。请你编写程序求出这个字符串中出现次数最多的字母。
 */
package bupt.jike;

import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

/**
 * @author liyasong
 * 2012-3-22
 */
public class Pro2008_2 {

	/**
	 * 这个程序写的太大题写作，待简化
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int groups = s.nextInt();
		char [] cc = new char[groups];
		for (int i = 0; i < groups; i++) {
			int num = s.nextInt();
			HashMap<Character, Integer> hMap = new HashMap<Character, Integer>(num);
			String str = s.next();
			for (char c : str.toCharArray()) {
				if (!hMap.containsKey(c)) {
					hMap.put(c, 1);
				} else {
					int value = hMap.get(c);
					hMap.put(c, value+1);
				}
			}
			TreeSet<Integer> set = new TreeSet<Integer>(hMap.values());
			for (char c : hMap.keySet()) {
				if (hMap.get(c) == set.last()) {
					cc[i] = c;
				}
			}
		}
		for (int i = 0; i < cc.length; i++) {
			System.out.println(cc[i]);
		}
	}

}
